var currentPage=1;
var sortTypeId="";
var propertyTypeId="";
var allSort="";
var addTimeSort="";
var gPriceSort="";
var dPriceSort="";
var collectNumSort="";
var saleNumSort="";
var shangquanid="";
var dianpuleixing="";
var	remaigoodss="";
var	shifoubaohuans="";
var	jingbidikous="";
var qujianshu="";
var qipijianshu="";

$(function(){
	currentPage=1;
     recommend21();
});
var currentPage=0;
var currentPage2=0;
var currentPage3=0;
var currentPage4=0;
var currentPage5=0;



var ss5=0;
  function recommend25(){
  	if(currentPage5==0 || currentPage5==1 || currentPage5==2 || ss5!=0){
  	 
currentPage=1;
currentPage2=1;
 currentPage3=1;
 currentPage4=1;
  		ss=0;
  		ss2=0;
  		ss3=0;
  		ss4=0;
  		$("#zaohuotuijian").html("");
  		$("#zaohuotuijian2").html("");
  		$("#zaohuotuijian3").html("");
  		$("#zaohuotuijian5").html("");
		$.ajax({
          url: urlcore + "/api/goods/selectGoodsList?current="+currentPage4+"&styleSort=4&goodsType="+remaigoodss+"&isReturnedOfSevenDays="+shifoubaohuans+"&sellerType="+dianpuleixing+"&betweenMoney="+qujianshu+"&tradeAreaId="+shangquanid,
			type: "get",
			dataType: 'json',
			contentType: "application/json;charset=utf-8",
			success: function(data) {
				if(data.success == true) {
					ss5=data.data.list.length;
					//alert(JSON.stringify());
				$.each(data.data.list,function(y,n){
					var zaohuotuijian= /*'<div class="w_ddcon1">'+
					'<div class="clearfix">'+*/
		   '<div class="public_goods">'+
				'<a href="7.0.0goods_detail.html?id='+n.id+'">'+
					'<dl>'+
						'<dt>'+
							'<img onerror="errorImg(this)" src="'+n.coverUrl+'" />'+
						'</dt>'+
						'<dd>'+
							'<h5>'+n.goodsTitle+'</h5>'+
							'<h6>&yen;'+n.packPrice+'</h6>'+ /*&yen;'+n.tradePrice+'-*/
						'</dd>'
					'</dl>'+
				'</a>'+
			'</div>';
//		'</div>'+
//		'</div>';
                 $("#zaohuotuijian5").append(zaohuotuijian);
				});
				} else if(data.code == 'OVERTIME') {
					var thisUrl = window.location.href;
					alert(thisUrl);
					if(thisUrl.indexOf('1.0.0denglu.html') <= -1) {
						top.window.location.href = "1.0.0denglu.html";
					}

				} else {
					if(data.msg != '空数据') {
						alert(data.msg)
					} else {
						$('#thiscount').text(0);
					}
				}

			},
			error: function() {
				alert("error");
			}
		});
		
  	}

}



var ss4=0;
  function recommend24(){
  	if(currentPage4==0 || currentPage4==1 || currentPage4==2 || ss4!=0){
currentPage=1;
currentPage2=1;
 currentPage3=1;
 currentPage5=1;
  		ss=0;
  		ss2=0;
  		ss3=0;
  		ss5=0;
  		$("#zaohuotuijian").html("");
  		$("#zaohuotuijian2").html("");
  		$("#zaohuotuijian3").html("");
  		$("#zaohuotuijian5").html("");
		$.ajax({
          url: urlcore + "/api/goods/selectGoodsList?current="+currentPage4+"&styleSort=4&goodsType="+remaigoodss+"&isReturnedOfSevenDays="+shifoubaohuans+"&sellerType="+dianpuleixing+"&betweenMoney="+qujianshu+"&tradeAreaId="+shangquanid,
			type: "get",
			dataType: 'json',
			contentType: "application/json;charset=utf-8",
			success: function(data) {
				if(data.success == true) {
					ss4=data.data.list.length;
					//alert(JSON.stringify());
				$.each(data.data.list,function(y,n){
					var zaohuotuijian= /*'<div class="w_ddcon1">'+
					'<div class="clearfix">'+*/
		   '<div class="public_goods">'+
				'<a href="7.0.0goods_detail.html?id='+n.id+'">'+
					'<dl>'+
						'<dt>'+
							'<img onerror="errorImg(this)" src="'+n.coverUrl+'" />'+
						'</dt>'+
						'<dd>'+
							'<h5>'+n.goodsTitle+'</h5>'+
							'<h6>&yen;'+n.packPrice+'</h6>'+
						'</dd>'
					'</dl>'+
				'</a>'+
			'</div>';
//		'</div>'+
//		'</div>';
                 $("#zaohuotuijian4").append(zaohuotuijian);
				});
				} else if(data.code == 'OVERTIME') {
					var thisUrl = window.location.href;
					alert(thisUrl);
					if(thisUrl.indexOf('1.0.0denglu.html') <= -1) {
						top.window.location.href = "1.0.0denglu.html";
					}

				} else {
					if(data.msg != '空数据') {
						alert(data.msg)
					} else {
						$('#thiscount').text(0);
					}
				}

			},
			error: function() {
				alert("error");
			}
		});
		
  	}

}



var ss3=0;
  function recommend23(){
  	if(currentPage3==0  ||currentPage3==1 || currentPage3==2 || ss3!=0){
  	 
currentPage=1;
currentPage2=1;
 currentPage4=1;
 currentPage5=1;
  		ss=0;
  		ss2=0;
  		ss4=0;
  		ss5=0;
  		$("#zaohuotuijian").html("");
  		$("#zaohuotuijian2").html("");
  		$("#zaohuotuijian4").html("");
  		$("#zaohuotuijian5").html("");
		$.ajax({
          url: urlcore + "/api/goods/selectGoodsList?current="+currentPage3+"&styleSort=3&goodsType="+remaigoodss+"&isReturnedOfSevenDays="+shifoubaohuans+"&sellerType="+dianpuleixing+"&betweenMoney="+qujianshu+"&tradeAreaId="+shangquanid,
			type: "get",
			dataType: 'json',
			contentType: "application/json;charset=utf-8",
			success: function(data) {
				if(data.success == true) {
					ss3=data.data.list.length;
					//alert(JSON.stringify());
				$.each(data.data.list,function(y,n){
					var zaohuotuijian= /*'<div class="w_ddcon1">'+
					'<div class="clearfix">'+*/
		   '<div class="public_goods">'+
				'<a href="7.0.0goods_detail.html?id='+n.id+'">'+
					'<dl>'+
						'<dt>'+
							'<img onerror="errorImg(this)" src="'+n.coverUrl+'" />'+
						'</dt>'+
						'<dd>'+
							'<h5>'+n.goodsTitle+'</h5>'+
							'<h6>&yen;'+n.packPrice+'</h6>'+
						'</dd>'
					'</dl>'+
				'</a>'+
			'</div>';
//		'</div>'+
//		'</div>';
                 $("#zaohuotuijian3").append(zaohuotuijian);
				});
				} else if(data.code == 'OVERTIME') {
					var thisUrl = window.location.href;
					alert(thisUrl);
					if(thisUrl.indexOf('1.0.0denglu.html') <= -1) {
						top.window.location.href = "1.0.0denglu.html";
					}

				} else {
					if(data.msg != '空数据') {
						alert(data.msg)
					} else {
						$('#thiscount').text(0);
					}
				}

			},
			error: function() {
				alert("error");
			}
		});
		
  	}

}

var ss2=0;
  function recommend22(){
  	if(currentPage2==0 || currentPage2==1 || currentPage2==2 || ss2!=0 ){
  	       
currentPage=1;
currentPage3=1;
 currentPage4=1;
 currentPage5=1;
  		ss=0;
  		ss3=0;
  		ss4=0;
  		ss5=0;
  		$("#zaohuotuijian").html("");
  		$("#zaohuotuijian3").html("");
  		$("#zaohuotuijian4").html("");
  		$("#zaohuotuijian5").html("");
		$.ajax({
          url: urlcore + "/api/goods/selectGoodsList?current="+currentPage2+"&styleSort=2&goodsType="+remaigoodss+"&isReturnedOfSevenDays="+shifoubaohuans+"&sellerType="+dianpuleixing+"&betweenMoney="+qujianshu+"&tradeAreaId="+shangquanid,
			type: "get",
			dataType: 'json',
			contentType: "application/json;charset=utf-8",
			success: function(data) {
				if(data.success == true) {
					ss2=data.data.list.length;
			
				$.each(data.data.list,function(y,n){
					var zaohuotuijian= /*'<div class="w_ddcon1">'+
					'<div class="clearfix">'+*/
		   '<div class="public_goods">'+
				'<a href="7.0.0goods_detail.html?id='+n.id+'">'+
					'<dl>'+
						'<dt>'+
							'<img onerror="errorImg(this)" src="'+n.coverUrl+'" />'+
						'</dt>'+
						'<dd>'+
							'<h5>'+n.goodsTitle+'</h5>'+
							'<h6>&yen;'+n.packPrice+'</h6>'+
						'</dd>'
					'</dl>'+
				'</a>'+
			'</div>';
//		'</div>'+
//		'</div>';
                 $("#zaohuotuijian2").append(zaohuotuijian);
				});
				} else if(data.code == 'OVERTIME') {
					var thisUrl = window.location.href;
					alert(thisUrl);
					if(thisUrl.indexOf('1.0.0denglu.html') <= -1) {
						top.window.location.href = "1.0.0denglu.html";
					}

				} else {
					if(data.msg != '空数据') {
						alert(data.msg)
					} else {
						$('#thiscount').text(0);
					}
				}

			},
			error: function() {
				alert("error");
			}
		});
		
  	}

}


var ss=0;
  function recommend21(){
  	if(ss!=0 ||currentPage==1 || currentPage==2){
  		
currentPage2=1;
currentPage3=1;
 currentPage4=1;
 currentPage5=1;
  		ss2=0;
  		ss3=0;
  		ss4=0;
  		ss5=0;
  		$("#zaohuotuijian2").html("");
  		$("#zaohuotuijian3").html("");
  		$("#zaohuotuijian4").html("");
  		$("#zaohuotuijian5").html("");
		$.ajax({
          url: urlcore + "/api/goods/selectGoodsList?current="+currentPage+"&styleSort=1&goodsType="+remaigoodss+"&isReturnedOfSevenDays="+shifoubaohuans+"&sellerType="+dianpuleixing+"&betweenMoney="+qujianshu+"&tradeAreaId="+shangquanid,
			type: "get",
			dataType: 'json',
			contentType: "application/json;charset=utf-8",
			success: function(data) {
				if(data.success == true) {
					ss=data.data.list.length;
					//alert(JSON.stringify());
				$.each(data.data.list,function(y,n){
					var zaohuotuijian= /*'<div class="w_ddcon1">'+
					'<div class="clearfix">'+*/
		   '<div class="public_goods">'+
				'<a href="7.0.0goods_detail.html?id='+n.id+'">'+
					'<dl>'+
						'<dt>'+
							'<img onerror="errorImg(this)" src="'+n.coverUrl+'" />'+
						'</dt>'+
						'<dd>'+
							'<h5>'+n.goodsTitle+'</h5>'+
							'<h6>&yen;'+n.packPrice+'</h6>'+
						'</dd>'
					'</dl>'+
				'</a>'+
			'</div>';
//		'</div>'+
//		'</div>';
                 $("#zaohuotuijian").append(zaohuotuijian);
				});
				} else if(data.code == 'OVERTIME') {
					var thisUrl = window.location.href;
					alert(thisUrl);
					if(thisUrl.indexOf('1.0.0denglu.html') <= -1) {
						top.window.location.href = "1.0.0denglu.html";
					}

				} else {
					if(data.msg != '空数据') {
						alert(data.msg)
					} else {
						$('#thiscount').text(0);
					}
				}

			},
			error: function() {
				alert("error");
			}
		});
		
  	}

}
   
   //搜索
   
function search(){
	
}



function shangquan(){
	  $("#shangquanquan").html("");
	$.ajax({
 url: urlcore + "/api/tradeArea/selectList",
			type: "get",
			dataType: 'json',
			contentType: "application/json;charset=utf-8",
			success: function(data) {
				if(data.success == true) {
					var i=0;
				$.each(data.data,function(y,n){
					var shangquanquan="";
					i++;
					if(i==1){
					shangquanquan+= '<li class="sq_curr" id="sq'+n.id+'">'+n.areaName+'</li>';
					}else{
						 shangquanquan+= '<li id="sq'+n.id+'">'+n.areaName+'</li>';
					}
					  $("#shangquanquan").append(shangquanquan);
				});
				} else if(data.code == 'OVERTIME') {
					var thisUrl = window.location.href;
					alert(thisUrl);
					if(thisUrl.indexOf('1.0.0denglu.html') <= -1) {
						top.window.location.href = "1.0.0denglu.html";
					}
				} else {
					if(data.msg != '空数据') {
						alert(data.msg)
					} else {
						$('#thiscount').text(0);
					}
				}

			},
			error: function() {
				alert("error");
			}
		});
}


function shaixuanshousuo(){
	var dianpusstype=$("#dianpuleixing").val();
	var remaigoodsstype=$("#remaigoodss").val();
	var shifoubaohuanstype=$("#shifoubaohuans").val();
	var jingbidikoustype=$("#jingbidikous").val();
    var zuishaozhitype=$("#zuishaozhi").val();
    var zuidazhitype=$("#zuidazhi").val();  	
    var qipijianshutype=$("#qipijianshu").val();
    dianpuleixing=dianpusstype;
	remaigoodss=remaigoodsstype;
	shifoubaohuans=shifoubaohuanstype;
	jingbidikous=jingbidikoustype;
    zuishaozhi=zuishaozhitype;
    zuidazhi=zuidazhitype;
/*    if(zuishaozhi<=zuidazhi){
    	alert("价格区间错误");
    	$("#zuidazhi").val("");
    	$("#zuishaozhi").val("");
    	return;
    }*/
    qujianshu=zuishaozhi+"-"+zuidazhi;
   currentPage=1;
   
	  $("#chanping").html("");
    qipijianshu=qipijianshutype;
    recommend(1);
    	$(".quxiao_left a").click(function(){               
			$(".cbp-spmenu-right").stop(true).animate({right:"-90%"},'slow');   
			$("#mask").remove();
		}); 
}


function selectallsshangquan(){
       	$("#shangquanxinxi").html("");
	    $.ajax({
        url:urlcore+"/api/tradeArea/selectList",
			type: "get",
			dataType: 'json',
			contentType: "application/json;charset=utf-8",
			success: function(data) {
				if(data.success == true) {
					var suns=0;
				$.each(data.data,function(y,h){
					suns++;
					var shangquanxinxi="";
				     if(suns==1){
			shangquanxinxi+='<li onclick="guanbi()">全部商圈</li>';
            shangquanxinxi+='<li onclick="selectshangquan('+h.id+',\''+h.areaName+'\')" id="'+h.id+'" >'+h.areaName+'</li>';

				     }else{
	shangquanxinxi+='<li onclick="selectshangquan('+h.id+',\''+h.areaName+'\')" id="'+h.id+'" >'+h.areaName+'</li>';

				     }
				
		        
			    $("#shangquanxinxi").append(shangquanxinxi);
					});
				}
			},
			error: function() {
				alert("error");
			}
		});
		
}
	
function selectshangquan(id,name){
	//alert("..."+name);
	$("#shangquanmingzi").html("");
	$("#shangquanmingzi").html(name);
	shangquanid=id;
	//$("#pfsq span").removeClass('up');
	$('#Shangquan').hide();

}